<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>季度柱形图</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .input-container {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            margin-bottom: 20px;
        }
        
        .input-group {
            display: flex;
            align-items: center;
        }
        
        label {
            margin-right: 10px;
            width: 80px;
        }
        
        input {
            width: 80px;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        
        button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        
        button:hover {
            background-color: #45a049;
        }
        
        .chart-container {
            display: flex;
            justify-content: space-around;
            align-items: flex-end;
            height: 400px;
            border-bottom: 2px solid #333;
            margin-top: 30px;
            padding-top: 20px;
        }
        
        .bar {
            width: 80px;
            background: linear-gradient(to top, #4CAF50, #45a049);
            margin: 0 10px;
            position: relative;
            transition: height 0.5s ease;
            border-radius: 5px 5px 0 0;
        }
        
        .bar-value {
            position: absolute;
            top: -25px;
            width: 100%;
            text-align: center;
            font-weight: bold;
        }
        
        .bar-label {
            margin-top: 10px;
            text-align: center;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <h1>季度柱形图</h1>
    
    <div class="input-container">
        <div class="input-group">
            <label for="q1">第一季度:</label>
            <input type="number" id="q1" min="0" max="100" value="65">
        </div>
        
        <div class="input-group">
            <label for="q2">第二季度:</label>
            <input type="number" id="q2" min="0" max="100" value="45">
        </div>
        
        <div class="input-group">
            <label for="q3">第三季度:</label>
            <input type="number" id="q3" min="0" max="100" value="80">
        </div>
        
        <div class="input-group">
            <label for="q4">第四季度:</label>
            <input type="number" id="q4" min="0" max="100" value="70">
        </div>
    </div>
    
    <button onclick="generateChart()">生成柱形图</button>
    
    <div class="chart-container">
        <div class="bar" id="bar1">
            <div class="bar-value" id="value1">65</div>
            <div class="bar-label">第一季度</div>
        </div>
        <div class="bar" id="bar2">
            <div class="bar-value" id="value2">45</div>
            <div class="bar-label">第二季度</div>
        </div>
        <div class="bar" id="bar3">
            <div class="bar-value" id="value3">80</div>
            <div class="bar-label">第三季度</div>
        </div>
        <div class="bar" id="bar4">
            <div class="bar-value" id="value4">70</div>
            <div class="bar-label">第四季度</div>
        </div>
    </div>
    
    <script>
        function generateChart() {
            // 获取输入值
            const q1 = parseInt(document.getElementById('q1').value) || 0;
            const q2 = parseInt(document.getElementById('q2').value) || 0;
            const q3 = parseInt(document.getElementById('q3').value) || 0;
            const q4 = parseInt(document.getElementById('q4').value) || 0;
            
            // 确保值在0-100之间
            const validateValue = (value) => Math.max(0, Math.min(100, value));
            
            // 更新柱形图
            document.getElementById('bar1').style.height = `${validateValue(q1)}%`;
            document.getElementById('value1').textContent = validateValue(q1);
            
            document.getElementById('bar2').style.height = `${validateValue(q2)}%`;
            document.getElementById('value2').textContent = validateValue(q2);
            
            document.getElementById('bar3').style.height = `${validateValue(q3)}%`;
            document.getElementById('value3').textContent = validateValue(q3);
            
            document.getElementById('bar4').style.height = `${validateValue(q4)}%`;
            document.getElementById('value4').textContent = validateValue(q4);
        }
        
        // 页面加载时初始化图表
        window.onload = generateChart;
    </script>
</body>
</html>
